namespace WebRtcProject.Models.Messages
{
    public class UserEventMessage : BaseMessage
    {
        public string UserId { get; set; } = string.Empty;
        public string UserName { get; set; } = string.Empty;
        public string EventType { get; set; } = string.Empty; // joined, left, room_changed, joined_room, left_room
        public string? RoomId { get; set; }
        public DateTime EventTime { get; set; } = DateTime.UtcNow;
        public Dictionary<string, object> Metadata { get; set; } = new();

        public UserEventMessage()
        {
            MessageType = nameof(UserEventMessage);
        }

        public static UserEventMessage UserJoined(string userId, string userName)
        {
            return new UserEventMessage
            {
                UserId = userId,
                UserName = userName,
                EventType = "joined"
            };
        }

        public static UserEventMessage UserLeft(string userId, string userName, string? roomId = null)
        {
            return new UserEventMessage
            {
                UserId = userId,
                UserName = userName,
                EventType = "left",
                RoomId = roomId
            };
        }

        public static UserEventMessage UserJoinedRoom(string userId, string userName, string roomId)
        {
            return new UserEventMessage
            {
                UserId = userId,
                UserName = userName,
                EventType = "joined_room",
                RoomId = roomId
            };
        }

        public static UserEventMessage UserLeftRoom(string userId, string userName, string roomId)
        {
            return new UserEventMessage
            {
                UserId = userId,
                UserName = userName,
                EventType = "left_room",
                RoomId = roomId
            };
        }

        public static UserEventMessage UserRoomChanged(string userId, string userName, string? oldRoomId, string? newRoomId)
        {
            return new UserEventMessage
            {
                UserId = userId,
                UserName = userName,
                EventType = "room_changed",
                RoomId = newRoomId,
                Metadata = new Dictionary<string, object>
                {
                    { "oldRoomId", oldRoomId ?? string.Empty },
                    { "newRoomId", newRoomId ?? string.Empty }
                }
            };
        }
    }
} 